package com.zhouyilin.bigevent2.validation;

import com.zhouyilin.bigevent2.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

//<给哪个注解提供校验，校验的数据类型>
public class StateValidation implements ConstraintValidator<State,String> {

    /**
     *
     * @param value   将来要校验的数据
     * @param constraintValidatorContext
     * @return false-校验不通过，true校验通过
     */
    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        if (value ==null) return false;
        if (value.equals("已发布")|| value.equals("草稿")){
            return true;
        }
        return false;
    }
}
